{% set pypi_name = 'os-win' %}
{% set upstream_version = upstream_version('5.3.0') %}
{% set rpm_release = '0' %}
{% set source = url_pypi() %}

Name:           {{ py2name('os-win') }}
Epoch:          {{ epoch('os-win') }}
Version:        {{ py2rpmversion() }}
Release:        {{ py2rpmrelease() }}
Summary:        Hyper-V library for OpenStack projects
License:        {{ license('Apache-2.0') }}
Group:          Development/Languages/Python
URL:            https://docs.openstack.org/{{ pypi_name }}
Source0:        {{ source }}
BuildRequires:  openstack-macros
BuildRequires:  {{ py3('Sphinx') }}
BuildRequires:  {{ py3('ddt') }}
BuildRequires:  {{ py3('devel') }}
BuildRequires:  {{ py3('eventlet') }}
BuildRequires:  {{ py3('mock') }}
BuildRequires:  {{ py3('oslo.concurrency') }}
BuildRequires:  {{ py3('oslo.i18n') }}
BuildRequires:  {{ py3('oslo.log') }}
BuildRequires:  {{ py3('oslotest') }}
BuildRequires:  {{ py3('pbr') }}
BuildRequires:  {{ py3('reno') }}
BuildRequires:  {{ py3('stestr') }}
BuildRequires:  {{ py3('testscenarios') }}
BuildRequires:  {{ py3('testtools') }}
BuildArch:      noarch

%description
Library contains Windows / Hyper-V code commonly used in the OpenStack projects:
nova, cinder, networking-hyperv.

%package -n {{ py2name(py_versions='py3') }}
Summary:        Hyper-V library for OpenStack projects
Requires:       {{ py3('Babel') }}
Requires:       {{ py3('eventlet') }}
Requires:       {{ py3('oslo.concurrency') }}
Requires:       {{ py3('oslo.config') }}
Requires:       {{ py3('oslo.i18n') }}
Requires:       {{ py3('oslo.log') }}
Requires:       {{ py3('oslo.service') }}
Requires:       {{ py3('oslo.utils') }}
Requires:       {{ py3('pbr') }}

%description -n {{ py2name(py_versions='py3') }}
Library contains Windows / Hyper-V code commonly used in the OpenStack projects:
nova, cinder, networking-hyperv.

%package -n {{ py2name() }}-doc
Summary:        Documentation for OpenStack Windows/Hyper-V Library
Group:          Documentation/HTML
BuildRequires:  {{ py3('Sphinx') }}
BuildRequires:  {{ py3('openstackdocstheme') }}

%description -n {{ py2name() }}-doc
Documentation for the Hyper-V library.

%prep
%autosetup -n {{ pypi_name }}-{{ upstream_version }}
%py_req_cleanup
# we don't want to run the hacking tests again (and don't want the needed deps)
rm -f os_win/tests/unit/test_hacking.py

%build
%{py3_build}

PBR_VERSION=%{version} %sphinx_build -b html doc/source doc/build/html
PBR_VERSION=%{version} %sphinx_build -b man doc/source doc/build/man
rm -rf doc/build/html/.{doctrees,buildinfo}
rm -rf doc/build/man/.{doctrees,buildinfo}

%install
%{py3_install}
install -p -D -m 644 doc/build/man/os-win.1 %{buildroot}/%{_mandir}/man1/os-win.1

%check
python3 -m stestr.cli run

%files -n {{ py2name(py_versions='py3') }}
%doc README.rst ChangeLog
%license LICENSE
%{python3_sitelib}/os_win*
%{python3_sitelib}/*.egg-info
%{_mandir}/man1/os-win.1*

%files -n {{ py2name() }}-doc
%doc doc/build/html
%license LICENSE

%changelog
